package com.example.administrator.exkotlin.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.PersistableBundle
import android.util.Log
import com.example.administrator.exkotlin.R

/**
 * activity 基类
 * 用于统计，管理
 * */
open class BaseActivity : AppCompatActivity() {

    private val TAG = "BaseActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.i(javaClass.simpleName, "onCreate")
        ActivityCollector.addActivity(this)
    }

    override fun onStart() {
        super.onStart()
        Log.i(javaClass.simpleName, "onStart")
    }

    override fun onRestart() {
        super.onRestart()
        Log.i(javaClass.simpleName, "onRestart")
    }

    override fun onResume() {
        super.onResume()
        Log.i(javaClass.simpleName, "onResume")
    }

    override fun onStop() {
        super.onStop()
        Log.i(javaClass.simpleName, "onStop")
    }

    override fun onPause() {
        super.onPause()
        Log.i(javaClass.simpleName, "onPause")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.i(javaClass.simpleName, "onDestroy")
        //在翻转屏幕时也会调用OnDestroy，这里不能执行通过统一管理来finsh()
//        ActivityCollector.removeActivity(this)
    }

    protected fun exsit() {
        ActivityCollector.removeActivity(this)
    }
}
